package com.itheima.d;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Test {
    public static void main(String[] args) {
        File file = new File("E:/a.txt");
        try (
                FileReader fr = new FileReader(file);
        ) {

            int len;
            char[] chars = new char[(int) file.length()];
            while ((len = fr.read(chars)) != -1) {
                System.out.println(new String(chars, 0, len));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        /*try (
                FileReader fr = new FileReader("E:/a.txt");
        ) {
            int len;
            char[] chars = new char[3];
            while ((len = fr.read(chars)) != -1) {
                System.out.println(new String(chars, 0, len));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }*/
    }
}
